package cmich.cps.scheduler.data;

import java.security.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import javax.persistence.Version;

import com.avaje.ebean.validation.NotNull;

/**
 * The Class Room.
 * 
 * @author Jonathan Kissinger <kissi1j@cmich.edu>
 */
@Entity
public class Room {
	
	/** The id. */
	@Id
	@GeneratedValue
	int id;
	
	/** The last update. */
	@Version
	Timestamp lastUpdate;
	
	/** The building. */
	@NotNull
	private String building;
	
	/** The number. */
	@NotNull
	private String number;
	
	/** The capacity. */
	private Integer capacity;
	
	/** The lab. */
	@NotNull
	private Boolean lab;
	
	/** The timeslots. */
	@Transient
	private List<String> timeslots = new ArrayList<String>();
	
	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	/**
	 * Gets the last update.
	 *
	 * @return the last update
	 */
	public Timestamp getLastUpdate() {
		return lastUpdate;
	}
	
	/**
	 * Sets the last update.
	 *
	 * @param lastUpdate the new last update
	 */
	public void setLastUpdate(Timestamp lastUpdate) {
		this.lastUpdate = lastUpdate;
	}
	
	/**
	 * Gets the building.
	 *
	 * @return the building
	 */
	public String getBuilding() {
		return building;
	}
	
	/**
	 * Sets the building.
	 *
	 * @param building the new building
	 */
	public void setBuilding(String building) {
		this.building = building;
	}
	
	/**
	 * Gets the number.
	 *
	 * @return the number
	 */
	public String getNumber() {
		return number;
	}
	
	/**
	 * Sets the number.
	 *
	 * @param number the new number
	 */
	public void setNumber(String number) {
		this.number = number;
	}
	
	/**
	 * Gets the capacity.
	 *
	 * @return the capacity
	 */
	public Integer getCapacity() {
		return capacity;
	}
	
	/**
	 * Sets the capacity.
	 *
	 * @param capacity the new capacity
	 */
	public void setCapacity(Integer capacity) {
		this.capacity = capacity;
	}
	
	/**
	 * Gets the lab.
	 *
	 * @return the lab
	 */
	public Boolean getLab() {
		return lab;
	}
	
	/**
	 * Sets the lab.
	 *
	 * @param lab the new lab
	 */
	public void setLab(Boolean lab) {
		this.lab = lab;
	}
	
	/**
	 * Gets the name.
	 *
	 * @return the name
	 */
	public String getName() {
		return this.building + " " + this.number;
	}
	
	/**
	 * Gets the timeslots.
	 *
	 * @return the timeslots
	 */
	public List<String> getTimeslots() {
		return timeslots;
	}
	
	/**
	 * Sets the timeslots.
	 *
	 * @param timeslots the new timeslots
	 */
	public void setTimeslots(List<String> timeslots) {
		this.timeslots.clear();
		this.timeslots.addAll(timeslots);
	}
	
	/**
	 * Removes the timeslot.
	 *
	 * @param timeslot the timeslot
	 */
	public void removeTimeslot(String timeslot) {
		this.timeslots.remove(timeslot);
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.building + " " + this.number;
	}
}